package com.common.exception;

import com.common.enums.error.ResultEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

import java.io.Serial;

/**
 * @author: stefanie-zy
 * @time: 2024/1/27-13:33
 * @description: 系统异常
 */
@EqualsAndHashCode(callSuper = true)
@Slf4j
@Data
@Schema(name = "系统异常")
public class StefanieException extends RuntimeException {
    @Serial
    private static final long serialVersionUID = 7704115512993099455L;

    @Schema(description = "错误码")
    private final Integer code;

    @Schema(description = "错误描述")
    private final String message;

    public StefanieException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public StefanieException(ResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.message = resultEnum.getMessage();
    }
}
